from concurrent.futures import ThreadPoolExecutor


def func_add(arg1, arg2):
    # 定义要在线程池中执行的函数
    print("{} * {} = {}".format(arg1, arg2, arg1 * arg2))
    return arg1 * arg2


with ThreadPoolExecutor(max_workers=5) as executor:
    for i in range(1, 10):
        arg1 = i
        for j in range(1, 10):
            arg2 = j
            # 创建包含5个线程的线程池
            future = executor.submit(func_add, arg1, arg2)  # 提交任务
try:
    result = future.result()
except Exception as e:
    print(f"任务执行出错: {e}")
